package com.example.netty.nio.serverAndClient;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws IOException {
        //1.创建客户端
        SocketChannel channel = SocketChannel.open();
        //2.连接服务器
        channel.connect(new InetSocketAddress("localhost",8080));
        while (true){
            Scanner scanner = new Scanner(System.in);
            String str = scanner.nextLine();
            channel.write(StandardCharsets.UTF_8.encode(str));
        }
    }
}
